package cn.njyd.corejava.thread.myday05;

public class VolatileDemo01 {
    private volatile static boolean flag = true;

    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(()->{
            while(true) {
                if (flag) {
                    continue;
                } else {
                    System.out.println(Thread.currentThread().getName()+"结束了");
                    break;
                }
            }
        });
        t1.start();
        Thread.sleep(1000);
        flag = false;
    }
}
